﻿<Window x:Class="SqLiteEditor.Forms.FrmAddTable"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:editor="http://icsharpcode.net/sharpdevelop/avalonedit"
        xmlns:staticData="clr-namespace:SqLiteEditor.Helper"
        Title="Add New Table" Height="416" Width="600" 
        Background="#FF2D3E5B" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Icon="/SqLiteEditor;component/Resources/DataToolBar/tabel.png" ShowInTaskbar="False" Topmost="True">

    <Window.Resources>
        <staticData:DataTypeList x:Key="DataTypeList"/>
        <staticData:DataTypeBool x:Key="DataTypeBool"/>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="50*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="30*"/>
            <RowDefinition Height="30"/>
        </Grid.RowDefinitions>
        
        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="White">
            <TextBlock HorizontalAlignment="Left" Margin="12,12,0,0" TextWrapping="Wrap" Text="Table Name : " VerticalAlignment="Top"/>
            <TextBox Name="txtTableName" HorizontalAlignment="Left" Height="23" Margin="91,7,0,0" TextWrapping="Wrap" Text="{Binding TableName,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="120"/>
            <CheckBox x:Name="Ch_Tbl_Exist" Content=" Check Exist" HorizontalAlignment="Left" Margin="230,10,0,0" VerticalAlignment="Top" Width="128"/>
            <Button x:Name="Btn_GenerateQuery" Content="Generate Query" HorizontalAlignment="Left" Margin="385,10,0,0" VerticalAlignment="Top" Width="177" Click="Btn_GenerateQuery_Click"/>

        </Grid>

            <DataGrid x:Name="SqliteStructureDataGrid" AutoGenerateColumns="False" Grid.Row="1"  IsReadOnly="False" Width="Auto" Margin="2" Grid.RowSpan="1" >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding ColumnName}" Header="ColumnName" Width="Auto"/>
                <DataGridTemplateColumn Header="DataType" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DataType}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Height="22" 
                                      ItemsSource="{StaticResource DataTypeList}"
                                      SelectedItem="{Binding DataType}"  />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>

                </DataGridTemplateColumn>
                <!--<DataGridTextColumn Binding="{Binding AllowNull}" Header="AllowNull" Width="Auto"/>-->
                <DataGridTemplateColumn Header="AllowNull" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox Height="22" IsChecked="{Binding AllowNull}" IsThreeState="False" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <CheckBox Height="22" IsChecked="{Binding AllowNull}" IsThreeState="False"  VerticalAlignment="Center" HorizontalAlignment="Center"/>         
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTextColumn Binding="{Binding DefaultValue}" Header="DefaultValue" Width="Auto"/>


                <DataGridTemplateColumn Header="PrimaryKey" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsPrimaryKey}"  VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsPrimaryKey}"  VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>

                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="AutoIncrement" Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsAutoIncrement}"  VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsAutoIncrement}"  VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>

                </DataGridTemplateColumn>

            </DataGrid.Columns>
        </DataGrid>

        <GridSplitter Grid.Row="2" Background="Black" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="7" ></GridSplitter>

        <editor:TextEditor Name="DMLEdittor" Grid.Row="3" FontFamily="Consolas" ShowLineNumbers="True" WordWrap="True" Grid.RowSpan="1" Margin="2" IsReadOnly="False" FontSize="14" />
        <Button Name="btnOk" Content="Ok" HorizontalAlignment="Left" Margin="507,5,0,0" Grid.Row="4" VerticalAlignment="Top" Width="75" Click="btnOk_Click"/>
        <Button Name="btnCancel" Content="Cancel" HorizontalAlignment="Left" Margin="427,5,0,0" Grid.Row="4" VerticalAlignment="Top" Width="75" IsCancel="True" Click="btnCancel_Click"/>

    </Grid>

</Window>
